package com.century.sjt.util;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

//十六进制字符转义
public class SrcUtil {

    //判断email格式是否正确
    public static boolean isEmail(String email) {
        String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);

        return m.matches();
    }
    //判断输入金额小于最大额度一万
    public static boolean toAcoument(String src){
//        if (src.equals("")||src==null){
//            return false;
//        }else {
//            double account=Double.parseDouble(src);
//            if (account>10000.00){
//                return true;
//            }
//        }
        return false;
    }
    public static String toHTMLx(String src){

        // 定义正则表达式来搜索中文字符的转义符号
        Pattern compile = Pattern.compile("&#.*?;");
        // 测试用中文字符
        Matcher matcher = compile.matcher(src);
        // 循环搜索 并转换 替换
        while (matcher.find()) {
            String group = matcher.group();
            // 获得16进制的码
            String hexcode = "0" + group.replaceAll("(&#|;)", "");
            // 字符串形式的16进制码转成int并转成char 并替换到源串中
            src = src.replaceAll(group, (char) Integer.decode(hexcode).intValue() + "");
        }
        return src;

    }
//特殊字符替换
    public static String tOHTML(String content) {
        if(content==null) return "";
        String html = content;

        html=html.replace("&ldquo;","\"");
        html=html.replace("&rdquo;","\"");

        return html;
    }
}
